package com.ticket.sass.admin.dto.input.role;

import com.ticket.sass.admin.util.ValidatorUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.AssertTrue;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;

/**
 * @author ywb
 * @date 2022-01-08 17:37
 */
@Data
@ApiModel(value = "权限保存输入DTO")
public class RolePowerSaveInput {
    @NotNull(message = "角色ID不能为空")
    @ApiModelProperty(value = "角色ID", required = true)
    private Long roleId;
    
    @Size(min = 1, message = "请选择资源")
    @ApiModelProperty(value = "资源ID", required = true)
    private List<Long> resourceIds;
    
    
    @AssertTrue(message = "资源ID不能重复")
    private boolean isUnique() {
        return ValidatorUtil.hasDuplicate(resourceIds);
    }
}
